<script setup lang="ts">
//声明属性
import {ref} from "vue";
import {permissions} from '@/api/platform/enterprise'
import {ElMessage} from "element-plus";
//声明事件
const emits = defineEmits(["close", "refresh"])
const props = defineProps({
  "visible": {
    type: Boolean,
    default: false
  }
})
//表单数据
const ruleForm = ref({
  id:0,
  empNum: "",
  accountNum:""
})
//保存权限
function saveQx(id){
  ruleForm.value.id=id
}
async function save(){
  let res = await permissions(ruleForm.value)
  if (res.code==200){
    ElMessage({
      message: '保存成功',
      type: 'success'
    })
    //刷新掉窗口的数据
    ruleForm.value={
      id:0,
      empNum: "",
      accountNum:""
    };
    //关闭窗口
    cls();
    //通知父窗口刷新数据
    emits("refresh");
  }
}
//暴露
defineExpose({saveQx})
//关闭窗口
function cls() {
  //抛出自定义事件
  emits("close");
}
</script>

<template>
  <el-dialog :model-value="visible" :close-on-click-modal="false" title="企业资料信息" width="500" @close="cls">
    <!--表单-->
    <el-form style="max-width: 400px;" :model="ruleForm" label-width="120px"
             class="demo-ruleForm" status-icon>
      <el-form-item label="可创建的员工数">
        <el-input v-model="ruleForm.empNum"/>
      </el-form-item>
      <el-form-item label="可创建的账套数">
        <el-input v-model="ruleForm.accountNum"/>
      </el-form-item>
      <el-button type="primary" @click="save">保存</el-button>
      <el-button @click="cls">不保存关闭</el-button>
    </el-form>
  </el-dialog>
</template>

<style scoped>

</style>
